<?php

declare(strict_types=1);

namespace App\Model;



/**
 * @property int $id
 * @property string $user_name
 * @property string $login_name
 * @property string $password
 * @property string $avatar
 * @property string $user_agent
 * @property string $last_login_ip
 * @property string $last_login_at
 * @property int $role_id
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property string $deleted_at
 */
class Admin extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'admins';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'user_name', 'login_name', 'password', 'avatar', 'user_agent', 'last_login_ip', 'last_login_at', 'role_id', 'created_at', 'updated_at', 'deleted_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'role_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    protected array $appends = ['role_name'];

    protected function getRoleNameAttribute()
    {
        return Role::withTrashed()->find($this->role_id)->role_name;
    }
}
